//
//  MLALEvent+LLAppLog.m
//  live.ly
//
//  Created by bob on 16/7/6.
//  Copyright © 2016年 musical.ly. All rights reserved.
//

#import "LLDiscoverNavigateConfigsManager.h"


@implementation MLALEvent (LLAppLog)

static NSDate *_time;

+ (void)tick
{
    _time = [NSDate date];
}

+ (void)tockAt:(NSString *)string
{
    NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:_time];
    NSLog(@"appLaunchTime:%@, desc:%@", [@(interval) stringValue], string);
}

+ (void)tock
{
    NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:_time];
    NSLog(@"appLaunchTime:%@", [@(interval) stringValue]);
}

+ (void)continueAs
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"continue_as" andParameters:nil] post];
}

+ (void)connectFb
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"connect_fb" andParameters:nil] post];
}

+ (void)connectTw
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"connect_tw" andParameters:nil] post];
}

+ (void)loginMusically
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"login_musically" andParameters:nil] post];
}

+ (void)login
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"login" andParameters:nil] post];
}

+ (void)findViaContacts
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"find_via_contacts" andParameters:nil] post];
}

+ (void)contactSkip
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"contact_skip" andParameters:nil] post];
}

+ (void)contactFollowAll
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"contact_follow_all" andParameters:nil] post];
}

+ (void)contactDone
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"contact_done" andParameters:nil] post];
}

+ (void)clickCaption
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_caption" andParameters:nil] post];
}

+ (void)startLive
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"start_live" andParameters:nil] post];
}

+ (void)clickDiscover
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_discover" andParameters:nil] post];
}

+ (void)slideDiscover
{
    [[MLALEvent event:LLLogUserSlideAction withAction:@"slide_discover" andParameters:nil] post];
}

+ (void)clickCamera
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_camera" andParameters:nil] post];
}

+ (void)slideCamera
{
    [[MLALEvent event:LLLogUserSlideAction withAction:@"slide_camera" andParameters:nil] post];
}

+ (void)slideCategory
{
    [[MLALEvent event:LLLogUserSlideAction withAction:@"slide_category" andParameters:nil] post];
}

+ (void)clickCategory
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_category" andParameters:nil] post];
}

+ (void)clickFindFriends
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_find_friends" andParameters:nil] post];
}

+ (void)clickPhoneContact
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_phone_contact" andParameters:nil] post];
}

+ (void)clickOtherProfile:(NSNumber *)user_id
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_other_profile" andParameters:@{ @"user_id" : user_id ?: @0 }] post];
}

+ (void)follow:(NSNumber *)user_id
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"follow" andParameters:@{ @"user_id" : user_id ?: @0 }] post];
}

+ (void)search
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"search" andParameters:nil] post];
}

+ (void)pushNotificationLiveSession:(NSString *)url;
{
    NSString *str = url;
    str = [str stringByReplacingOccurrencesOfString:@"lively://live/" withString:@""];
    str = [str stringByReplacingOccurrencesOfString:@"test" withString:@""];
    u_int64_t liveID = strtoull([str cStringUsingEncoding:NSASCIIStringEncoding], NULL, 10);

    [[MLALEvent event:LLLogUserClickAction withAction:@"push_notification_live_session" andParameters:@{@"current_room" : @(liveID)}] post];
}

+ (void)hostCloseLivelyDueTo:(NSString *)reason
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_close_live_session"
        andParameters:@{ @"reason" : reason ?: @"" }] post];
}

+ (void)clickLiveSessionWithUserID:(NSNumber *)user_id channel:(NSString *)channel scm:(NSString *)scm currentRoom:(NSNumber *)current_room
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_live_session"
        andParameters:@{ @"user_id" : user_id ?: @0,
                         @"channel" : channel ?: @"",
                         @"scm" : scm ?: @"",
                         @"current_room" : current_room ?: @0 }] post];
}

+ (void)clickUsername:(NSNumber *)user_id
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_username" andParameters:@{ @"user_id" : user_id ?: @0 }] post];
}

+ (void)turnOnPostNotificationWithUserID:(NSNumber *)user_id scm:(NSString *)scm channel:(NSString *)channel
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"turn_on_post_notification"
        andParameters:@{ @"user_id" : user_id ?: @0,
                         @"scm" : scm ?: @"",
                         @"channel" : channel ?: @"" }] post];
}

+ (void)shareFb
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"share_fb" andParameters:nil] post];
}

+ (void)shareTw
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"share_tw" andParameters:nil] post];
}

+ (void)inviteText
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"invite_text" andParameters:nil] post];
}

+ (void)inviteMessager
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"invite_messager" andParameters:nil] post];
}

+ (void)musicallyProfile:(NSNumber *)user_id
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"musically_profile" andParameters:@{ @"user_id" : user_id ?: @0 }] post];
}

+ (void)clickLeaderboard
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_leaderboard" andParameters:nil] post];
}

// ------------------------------------

+ (void)trafficControlDialogShowed
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"trafficControlDialogShowed" andParameters:nil] post];
}

+ (void)openedLiveWithSCM:(NSString *)scm
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"openedLiveWithSCM" andParameters:@{ @"scm" : scm ?: @"" }] post];
}

+ (void)openedLiveFromPopularStream
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"openedLiveFromPopularStream" andParameters:nil] post];
}

+ (void)openedLiveFromFriendStream
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"openedLiveFromFriendStream" andParameters:nil] post];
}

+ (void)openedCastFromFriendStream
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"openedCastFromFriendStream" andParameters:nil] post];
}

+ (void)findFriendTapped
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"findFriendTapped" andParameters:nil] post];
}

+ (void)followedAtSCM:(NSString *)scm
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"followedAtSCM" andParameters:@{ @"scm" : scm ?: @"" }] post];
}

+ (void)turnOnPostNotificationAtSCM:(NSString *)scm
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"turnOnPostNotificationAtSCM" andParameters:@{ @"scm" : scm ?: @"" }] post];
}

+ (void)profileGotoMusicallyTapped:(BOOL)installed
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"profileGotoMusicallyTapped" andParameters:@{ @"installed" : @(installed) }] post];
}

+ (void)audienceFollowedHostDuringLive
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"audienceFollowedHostDuringLive" andParameters:nil] post];
}

+ (void)hostFollowedAudienceDuringLive
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"hostFollowedAudienceDuringLive" andParameters:nil] post];
}

+ (void)audienceFollowedAudienceDuringLive
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"audienceFollowedAudienceDuringLive" andParameters:nil] post];
}

+ (void)livePreviewStarted
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"livePreviewStarted" andParameters:nil] post];
}

+ (void)livePreviewCommited
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"livePreviewCommited" andParameters:nil] post];
}

+ (void)livePreviewStartedPlaying
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"livePreviewStartedPlaying" andParameters:nil] post];
}

+ (void)pushNotificationReceived:(NSDictionary *)userInfo
{
    NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:userInfo];
    info[@"configClustersInner"] = [LLDiscoverNavigateConfigsManager sharedInstance].configClustersInner;
    info[@"configClusters"] = [LLDiscoverNavigateConfigsManager sharedInstance].configClusters;
    [[MLALEvent event:LLLogGeneralEvent withAction:@"pushNotificationReceived" andParameters:userInfo] post];
}

+ (void)pushNotificationTapped:(NSDictionary *)userInfo
{
    NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:userInfo];
    info[@"configClustersInner"] = [LLDiscoverNavigateConfigsManager sharedInstance].configClustersInner;
    info[@"configClusters"] = [LLDiscoverNavigateConfigsManager sharedInstance].configClusters;
    [[MLALEvent event:LLLogGeneralEvent withAction:@"pushNotificationTapped" andParameters:userInfo] post];
}

#pragma mark - find friends by contact

+ (void)uploadContacts
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"uploadContacts" andParameters:nil] post];
}

+ (void)followContactFriends
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"followContactFriends" andParameters:nil] post];
}

+ (void)af_topup:(NSString *)productId price:(NSNumber *)price locale:(NSString *)locale
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"mus_af_topup" andParameters:@{ @"productId" : productId ?: @"",
                                                                                    @"price" : price ?: @0,
                                                                                    @"locale" : locale ?: @"" }] post];
}

+ (void)af_buyGift:(NSString *)giftId andCount:(NSNumber *)count
{
    [[MLALEvent event:LLLogGeneralEvent withAction:@"mus_af_buy_gift" andParameters:@{ @"giftId" : giftId ?: @"",
                                                                                       @"count" : count ?: @0 }] post];
}

+ (void)shareLiveSessionToInstagramClicked
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"share_ins" andParameters:nil] post];
}

+ (void)canGuestCheckWithResult:(NSString *)failReasonOrNil hostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID guestCID:(NSString *)guestCID
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"guest_cid"] = guestCID;
    dict[@"fail_reason"] = failReasonOrNil;

    [[MLALEvent event:LLLogSysResponseAction withAction:@"guest_showup" andParameters:dict] post];
}

+ (void)clickStartGuestingWithHostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID guestCID:(NSString *)guestCID
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"guest_cid"] = guestCID;
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_guest" andParameters:dict] post];
}

+ (void)guestingConnectingWithHostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID sessionID:(NSString *)sessionID
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"session_id"] = sessionID;
    [[MLALEvent event:LLLogSysResponseAction withAction:@"guest_connecting" andParameters:dict] post];
}

+ (void)invitedAsGuestReceviedWithHostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID sessionID:(NSString *)sessionID autoRejectReason:(NSString *)failReason
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"session_id"] = sessionID;
    dict[@"fail_reason"] = failReason;
    [[MLALEvent event:LLLogSysResponseAction withAction:@"invite_to_be_guest" andParameters:dict] post];
}

+ (void)guestingGuestClickAccpetWithHostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID sessionID:(NSString *)sessionID
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"session_id"] = sessionID;
    [[MLALEvent event:LLLogUserClickAction withAction:@"guest_click_accept" andParameters:dict] post];
}

+ (void)guestingGuestClickHangupWithHostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID sessionID:(NSString *)sessionID
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"session_id"] = sessionID;
    [[MLALEvent event:LLLogUserClickAction withAction:@"guest_click_decline" andParameters:dict] post];
}

+ (void)guestingVideoShownWithHostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID sessionID:(NSString *)sessionID
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"session_id"] = sessionID;
    [[MLALEvent event:LLLogSysResponseAction withAction:@"guest_success" andParameters:dict] post];
}

+ (void)guestingHostClickHangupWithHostUserID:(unsigned long long)hostUserID guestUserID:(unsigned long long)guestUserID sessionID:(NSString *)sessionID
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"host_user_id"] = @(hostUserID);
    dict[@"guest_user_id"] = @(guestUserID);
    dict[@"session_id"] = sessionID;
    [[MLALEvent event:LLLogUserClickAction withAction:@"host_click_decline" andParameters:dict] post];
}

+ (void)clickCategoryWithName:(NSString *)name
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_category_item" andParameters:@{ @"tag" : name ?: @"" }] post];
}

+ (void)castPlayerEndPlay:(NSNumber *)castID playTime:(NSNumber *)playTime videoLength:(NSNumber *)videoLength videoIndex:(NSNumber *)videoIndex castCountOfChannel:(NSNumber *)castCount channelID:(NSNumber *)channelID channelType:(NSNumber *)channelType castAuthorID:(NSNumber *)userID playType:(NSNumber *)playType
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"cid"] = castID;
    dict[@"pt"] = playTime;
    dict[@"vl"] = videoLength;
    dict[@"vi"] = videoIndex;
    dict[@"cc"] = castCount;
    dict[@"chid"] = channelID;
    dict[@"ct"] = channelType;
    dict[@"uid"] = userID;
    dict[@"ptp"] = playType;

    [[MLALEvent event:LLLogSysPlayAction withAction:@"cast_end_play" andParameters:dict] post];
}

+ (void)clickMyChannel
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_my_channel" andParameters:nil] post];
}

+ (void)clickFriendLive:(NSNumber *)room_id userID:(NSNumber *)user_id
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_friend_live" andParameters:@{ @"room_id" : room_id ?: @0,
                                                                                            @"user_id" : user_id ?: @0 }] post];
}

+ (void)clickFriendNonlive:(NSNumber *)channel_id userID:(NSNumber *)user_id
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_friend_nonlive" andParameters:@{
        @"user_id" : user_id ?: @0,
        @"channel_id" : channel_id ?: @0
    }] post];
}

+ (void)clickPopularLive:(NSString *)scm roomID:(NSNumber *)room_id userID:(NSNumber *)user_id
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_popular_live" andParameters:@{
        @"scm" : scm ?: @"",
        @"room_id" : room_id ?: @0,
        @"user_id" : user_id ?: @0
    }] post];
}

+ (void)clickSendCast
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"send_cast" andParameters:nil] post];
}

+ (void)clickWhiteButton:(NSNumber *)record_duration
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_white_button" andParameters:@{ @"record_duration" : record_duration ?: @0 }] post];
}

+ (void)clickDiscardCast
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"discard_cast" andParameters:nil] post];
}

+ (void)clickDownloadCast
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"download_cast" andParameters:nil] post];
}

#pragma mark - Tab

+ (void)clickChannelsTab
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_channels_tab" andParameters:nil] post];
}

+ (void)clickExploreTab
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_explore_tab" andParameters:nil] post];
}

+ (void)clickCreate
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_create" andParameters:nil] post];
}

+ (void)clickLiveBroadcast
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_live_broadcast" andParameters:nil] post];
}

+ (void)clickGroupVideoChat
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_group_video_chat" andParameters:nil] post];
}

+ (void)clickMore
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_more" andParameters:nil] post];
}

+ (void)broadcastMobileGame
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"broadcast_a_mobile_game" andParameters:nil] post];
}

+ (void)recordMoment
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"record_a_moment" andParameters:nil] post];
}

#pragma mark - discovery

+ (void)clickDiscoveryCategory:(NSNumber *)categoryID
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_category" andParameters:@{ @"category_id" : categoryID ?: @0 }] post];
}

+ (void)clickCategoryLive:(NSNumber *)room_id userID:(NSNumber *)user_id categoryID:(NSNumber *)categoryID
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_category_live" andParameters:@{ @"room_id" : room_id ?: @0,
                                                                                              @"user_id" : user_id ?: @0,
                                                                                              @"category_id" : categoryID ?: @0 }] post];
}

+ (void)clickDiscoverySearch
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_serach" andParameters:nil] post];
}

+ (void)clickDiscoveryFindFriends
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_find_friends" andParameters:nil] post];
}

#pragma mark - LiveChat
+ (void)clickLiveChat
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_livechat" andParameters:nil] post];
}

+ (void)clickLiveChatInvite:(unsigned long long)partyID
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"livechat_invite" andParameters:@{ @"pid" : @(partyID) }] post];
}

+ (void)clickLiveChatPush:(NSString *)url
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_livechat_push" andParameters:@{ @"url" : url ?: @"" }] post];
}

+ (void)livechatPeopleChange:(unsigned long long)partyID peopleCount:(NSUInteger)count
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"livechat_people_change" andParameters:@{ @"pid" : @(partyID),
                                                                                                   @"count" : @(count) }] post];
}

+ (void)clickRedButton
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_red_button" andParameters:nil] post];
}

+ (void)clickToTheWorld
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_to_the_world" andParameters:nil] post];
}

+ (void)clickGoLive
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_go_live" andParameters:nil] post];
}

+ (void)clickWithFriends
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_with_friends" andParameters:nil] post];
}

#pragma mark - reward

+ (void)clickFreeCoinsInRoom
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_free_coins" andParameters:nil] post];
}

+ (void)clickCollectFreeCoinsInSetting
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_collect_free_coins" andParameters:nil] post];
}

+ (void)clickWatchAds
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_watch_ads" andParameters:nil] post];
}

+ (void)clickWatchNextRewardAds
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_watch_next_ads" andParameters:nil] post];
}

#pragma mark - push notification

+ (void)tokenRegister:(NSNumber *)user_id deviceID:(NSString *)deviceID
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"TOKEN_REGISTER" andParameters:@{ @"user_id" : user_id ?: @0,
                                                                                           @"deviceID" : deviceID ?: @"" }] post];
}

+ (void)tokenUnRegister:(NSNumber *)user_id deviceID:(NSString *)deviceID
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"TOKEN_UNREGISTER" andParameters:@{ @"user_id" : user_id ?: @0,
                                                                                             @"deviceID" : deviceID ?: @"" }] post];
}

#pragma makr - onboarding

+ (void)slideOnboardingFirstVideoSlide
{
    [[MLALEvent event:LLLogUserSlideAction withAction:@"onboarding_first_video_slide" andParameters:nil] post];
}

+ (void)slideOnboardingSecondVideoSlide
{
    [[MLALEvent event:LLLogUserSlideAction withAction:@"onboarding_second_video_slide" andParameters:nil] post];
}

+ (void)clickSignUp
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_sign_up" andParameters:nil] post];
}

+ (void)clickLogIn
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_log_in" andParameters:nil] post];
}

+ (void)clickSwitchAccount
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"switch_account" andParameters:nil] post];
}

+ (void)clickSignupWithPhone
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"signup_with_phone" andParameters:nil] post];
}

+ (void)clickSignupWithMusically
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"signup_with_musically" andParameters:nil] post];
}

+ (void)clickSignupWithFacebook
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"signup_with_facebook" andParameters:nil] post];
}

+ (void)clickCreateAccount
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"create_account" andParameters:nil] post];
}

+ (void)clickPhoto
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_photo" andParameters:nil] post];
}

+ (void)clickFullName
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"full_name" andParameters:nil] post];
}

+ (void)clickSetUpContinue
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"set_up_continue" andParameters:nil] post];
}

+ (void)clickSelfieUpload
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"selfie_upload" andParameters:nil] post];
}

+ (void)clickSelfieSkip
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"selfie_skip" andParameters:nil] post];
}

+ (void)clickConnectToFb
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"connect_to_fb" andParameters:nil] post];
}

+ (void)clickFbSkip
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"fb_skip" andParameters:nil] post];
}

+ (void)clickFbFollowAll
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"fb_follow_all" andParameters:nil] post];
}

+ (void)clickFbDone
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"fb_done" andParameters:nil] post];
}

#pragma mark - open&close

+ (void)openApp:(BOOL)firstLaunch
{
    NSDictionary *dic;
    if (firstLaunch) {
        dic = @{ @"first_launch" : @1 };
    } else {
        dic = @{ @"first_launch" : @0 };
    }
    [[MLALEvent event:LLLogSysGeneralParam withAction:@"open_app" andParameters:dic] post];
}

+ (void)closeApp
{
    [[MLALEvent event:LLLogSysGeneralParam withAction:@"close_app" andParameters:nil] post];
}

+ (void)pushReceived:(NSString *)identifier
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"push_received" andParameters:@{ @"push_received" : identifier ?: @"" }] post];
}

#pragma mark - face
+ (void)selectedFaceWithID:(NSString *)faceID
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"face_select" andParameters:@{ @"fid" : faceID ?: @"" }] post];
}

static NSDate *lastFaceRecordingStartTime;
static NSString *lastFaceRecoringID;

+ (void)startRecordingWithFace:(NSString *)faceID
{
    lastFaceRecoringID = faceID;
    lastFaceRecordingStartTime = [NSDate date];
}

+ (void)endRecordingWithFace
{
    if (lastFaceRecordingStartTime && lastFaceRecoringID) {
        NSTimeInterval interval = -[lastFaceRecordingStartTime timeIntervalSinceNow];
        [[MLALEvent event:LLLogUserClickAction withAction:@"face_record" andParameters:@{ @"fid" : lastFaceRecoringID ?: @"",
                                                                                          @"time" : @(interval) }] post];
    }
}

#pragma mark - gift

+ (void)clickSendGift:(NSNumber *)giftID scm:(NSString *)scm
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"gift_id"] = giftID ?: @0;
    dict[@"scm"] = scm;

    [[MLALEvent event:LLLogUserClickAction withAction:@"click_send_gift" andParameters:dict] post];
}

+ (void)verifyDigitsResult:(BOOL)success
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"result"] = @(success) ?: @0;
    [[MLALEvent event:LLLogSysResponseAction withAction:@"verify_digit_result" andParameters:dict] post];
}

+ (void)clickProduction:(NSString *)productionID
{
    [[MLALEvent event:LLLogUserClickAction withAction:@"click_production" andParameters:@{ @"production_id" : productionID ?: @"" }] post];
}

+ (void)popupVerify
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"popup_verify" andParameters:nil] post];
}

#pragma mark - guesting

+ (void)clickSendGuestingRequest
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"click_send_guesting_request" andParameters:nil] post];
}

+ (void)clickAcceptGuestingRequest
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"click_accept_guesting_request" andParameters:nil] post];
}

+ (void)clickGuestingSuggest
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"click_guesting_suggest" andParameters:nil] post];
}

+ (void)accept_guest_success
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"accept_guest_success" andParameters:nil] post];
}

#pragma mark - live

+ (void)createObsSuccess
{
    [[MLALEvent event:LLLogSysResponseAction withAction:@"create_obs_success" andParameters:nil] post];
}

+ (void)watchLiveWithTag:(NSString *)tag type:(NSString *)type duration:(NSNumber *)duration roomID:(NSNumber *)roomID originalRoomId:(NSNumber *)originalRoomID scm:(NSString *)scm
{
    NSMutableDictionary *dict = [@{} mutableCopy];
    dict[@"tag"] = tag ?: @"";
    dict[@"type"] = type ?: @"";
    dict[@"duration"] = duration ?: @0;
    dict[@"room_id"] = roomID ?: @0;
    dict[@"original_room_id"] = originalRoomID ?: @0;
    dict[@"scm"] = scm ?: @"";

    [[MLALEvent event:LLLogSysResponseAction withAction:@"watch_live" andParameters:dict] post];
}

@end
